import scala.beans.BeanProperty

class Person(@BeanProperty var name: String = "",
             @BeanProperty var sex: String = "male",
             @BeanProperty var age: Int = 0) {
  def print(): Unit = {
    println("name: " + name, "sex: " + sex, "age: " + age.toString)
  }
}

class Student(n: String = "", s: String = "male", a: Int = 0) extends Person(n, s, a) {
  private[this] var _school: String = "JiangXi Normal University"

  def school: String = _school

  def school_=(value: String): Unit = {
    _school = value
  }

  private[this] var _studentID: Int = 0

  def studentID: Int = _studentID

  def studentID_=(value: Int): Unit = {
    _studentID = value
  }

  override def print(): Unit = {
    println("name: " + name, "sex: " + sex, "age: " + age.toString, _school, _studentID)
  }
}

object test {
  def main(args: Array[String]): Unit = {
    val p = new Person("Bill", "male", 36)
    p.print()
    println(p.getName(), p.getSex(), p.getAge())
    p.setName("Bili")
    p.setAge(35)
    p.setSex("female")
    p.print()

    val t = new Person("Anton", "male")
    t.print()

    val stu = new Student("Bo", "male", 15)
    stu.print()
    stu.setName("Bob")
    stu.studentID = 2060
    stu.print()
  }
}

/*
* 构造Person类。
* 包括姓名(name)，性别(sex)和年龄(age)。
* 提供所有属性的set和get函数，提供print函数打印其信息；
* 构造Student类继承Person类，并增加学校(school)，学号(studentID)。
* 并对其进行测试。
* ref :
* 1. https://www.runoob.com/scala/scala-classes-objects.html
* 2. https://docs.scala-lang.org/overviews/scala-book/classes.html
* 3. https://www.cnblogs.com/shihuc/p/5073753.html
* 4. https://blog.csdn.net/qq_29499107/article/details/80732989
* */

